<script>
$(document).ready(function() {
    
    $('.d_reporting_to').change(function() {
        var usergroup        = $(this).val();
        var reportingto        = $('#reportingto').val();        
        
        $.post(
            '<?=base_url()?>index.php/user_management/user_repto', 
            {usergroup:usergroup, reportingto:reportingto},
            function(data) {
                if(data.status == 'OK') {
                    document.getElementById("divReporting").innerHTML = data.pesan;
                }
            },
            "json"
        ).error(function() {
            alert("-");
        });
    });
    
	$('.d_cari').click(function() {
        var uid  	= $("#username").val();
		var name	= $("#name").val();
		var nik		= $("#nik").val();
		var group	= $("#group").val();
		var report	= $("#reportingto").val();
		var hape	= $("#hape").val();
		var email	= $("#email").val();
        
        $.post(
            '<?=base_url()?>index.php/user_management/search_result', 
            {uid:uid, name:name, nik:nik, group:group, report:report, hape:hape, email:email},
            function(data) {
                if(data.status == 'OK') {
					if(data.jumlah==0){
							alert("Data Pengguna tidak ditemukan");
					}
                    document.getElementById("tabel").innerHTML = data.pesan;
                }
            },
            "json"
        ).error(function() {
            alert("-");
        });
    });
	
	
	$('.d_keluarkan').live("click",function() {
        var id  	= $(this).attr("id");
        
        $.post(
            '<?=base_url()?>index.php/user_management/keluarkan_user', 
            {id:id},
            function(data) {
                if(data.status == 'OK') {
                    alert("User berhasil dikeluarkan");
                }
            },
            "json"
        ).error(function() {
            alert("-");
        });
    });
});


function jump_url(targ,selObj,restore){ //v3.0
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}
</script>

<div class="box" style="min-height:900px;">
        <!-- box / title -->
        <div class="title">
                <h5>Users Management :: Search</h5>
                <ul class="links">
                        <!-- <li><a href="<?=base_url()."index.php/".$this->uri->segment(1)?>/index/add">New User</a></li>
                        <li><a href="<?=base_url()."index.php/".$this->uri->segment(1)?>">List Data</a></li>
						<li><a href="<?=base_url().'index.php/'.$this->uri->segment(1)?>/search">Search</a></li> -->
                </ul>
        </div>
        <!-- end box / title -->
        
                <form id="form" action="<?=$_SERVER['PHP_SELF']?>" method="post">
                <div class="form">
                        <div class="fields">
                        
                                <div class="field">
                                        <div class="label">
                                                <label for="username">User ID:</label>
                                        </div>
                                        <div class="input">
                                                <input type="text" id="username" name="username" class="medium" />
                                        </div>
                                </div>
								<div class="field">
                                        <div class="label">
                                                <label for="name">Name:</label>
                                        </div>
                                        <div class="input">
                                                <input type="text" id="name" name="name" class="medium" />
                                        </div>
                                </div>
                                <div class="field">
                                        <div class="label">
                                                <label for="nik">NIK:</label>
                                        </div>
                                        <div class="input">
                                                <input type="text" id="nik" name="nik" class="medium" />
                                        </div>
                                </div>
                                <div class="field">
                                        <div class="label">
                                                <label for="usergroup">User Group:</label>
                                        </div>
                                        <div class="input">
                                                <?php
                                                $getUserGroup	= $this->muserrole->getUserGroup();
                                                echo'<select name="usergroup" id="group">
												<option value="">Pilih</option>';
                                                foreach($getUserGroup as $r){
                                                        echo'<option value="'. $r->user_group_id .'" >'. $r->user_group_name .'</option>';
                                                }
                                                echo'</select>';
                                                ?>
                                        </div>
                                </div>
                                <div class="field">
                                        <div class="label">
                                                <label for="reportingto">Reporting To:</label>
                                        </div>
                                        <div class="input">
                                                <?php
                                                $getUser	= $this->musers->getUser();
                                                echo'<select name="reportingto" id="reportingto">
												<option value="">Pilih</option>';
                                                foreach($getUser as $r){
                                                        echo'<option value="'. $r->user_id .'">'. $r->user_name .'</option>';
                                                }
                                                echo'</select>';
                                                ?>
                                        </div>
                                </div>
                                <div class="field">
                                        <div class="label">
                                                <label for="hape">Mobile Number:</label>
                                        </div>
                                        <div class="input">
                                                <input type="text" id="hape" name="hape" class="medium" />
                                        </div>
                                </div>
                                
                                <div class="field">
                                        <div class="label">
                                                <label for="email">E-Mail:</label>
                                        </div>
                                        <div class="input">
                                                <input type="text" id="email" name="email" class="medium" />
                                        </div>
                                </div>
                                
                                <div class="buttons">
                                        <input type="button" class="d_cari" name="submit" value="Cari Data" />
                                </div>
                        </div>
                </div>
                </form><br><br>&nbsp;
        
        <div class="table" id="tabel">


        </div>
</div>